#!/usr/bin/env node

const Koa = require('koa'),
      fakeAsync = require('./lib/task.js');
const app = new Koa();

app.use(async (ctx,next)=>{ 
  const start = Date.now();
  await next();
  const end = Date.now();
  const cost = end-start;

  console.log(`${ctx.method} ${ctx.path} ${cost}ms`);  
});

app.use(async (ctx,next)=>{ 
  ctx.body = 'hello world' + await fakeAsync(1) + 'ms';
 
});

app.listen(8080);

